local jingying_choose = fk.CreateSkill {
  name = "#lb__jingying_choose",
}

Fk:loadTranslationTable {
  ["#lb__jingying_choose"] = "镜影",
}

jingying_choose:addEffect("active", {
  interaction = function(self, player)
    local all = { "black", "red" }
    local ask = {}
    for _, id in ipairs(player:getCardIds("he")) do
      table.insertIfNeed(ask, Fk:getCardById(id):getColorString())
    end
    return UI.ComboBox {
      choices = ask,
      all_choices = all,
    }
  end,
  card_filter = function(self, player, to_select, selected)
    local n
    if self.interaction.data == nil then
      n = 1
    else
      n = self.interaction.data == "red" and #self.extra_data.red or #self.extra_data.black
    end
    return #selected < n and Fk:getCardById(to_select):getColorString() == self.interaction.data and
        (table.contains(player:getHandlyIds(), to_select) or table.contains(player:getCardIds("e"), to_select))
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    --目标数要等于选牌数，目标展示牌要和选择牌颜色相同，目标能被冰杀指定
    if self.interaction.data == nil then return false end
    return #selected < #selected_cards and
        table.contains((self.interaction.data == "red" and self.extra_data.red or self.extra_data.black), to_select.id)
        and player:canUseTo(Fk:cloneCard("ice__slash"), to_select, { bypass_distances = true, bypass_times = true })
  end,
  feasible = function(self, player, selected, selected_cards)
    return #selected > 0 and #selected == #selected_cards and self.interaction.data
  end,
})

return jingying_choose
